unit add_step_unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, data_module, ImgList, DBCtrls,
  StdCtrls, Mask, ComCtrls, cxGraphics,
  cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
  dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel,
  dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
  dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
  dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010,
  dxSkinWhiteprint, dxSkinXmas2008Blue, cxSpinEdit, cxDBEdit, cxDropDownEdit,
  cxCalendar, cxTextEdit, cxMaskEdit, cxLookupEdit, cxDBLookupEdit,
  cxDBLookupComboBox, Vcl.Grids, Vcl.ValEdit, cxStyles, dxSkinscxPCPainter,
  cxCustomData, cxFilter, cxData, cxDataStorage, Data.DB, cxDBData,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
  cxClasses, cxGridCustomView, cxGrid;

type
  Tadd_step_form = class(TForm)
    Label1: TLabel;
    Label3: TLabel;
    ok_button: TButton;
    cancek_button: TButton;
    ImageList1: TImageList;
    study_plan_combo: TcxDBLookupComboBox;
    cxDBTextEdit1: TcxDBTextEdit;
    Label2: TLabel;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGrid1DBTableView1Column1: TcxGridDBColumn;
    cxGrid1DBTableView1Column2: TcxGridDBColumn;
    Label4: TLabel;
    cxDBTextEdit2: TcxDBTextEdit;
    procedure study_plan_comboPropertiesChange(Sender: TObject);
    procedure cxDBTextEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
    groups_ids:array[1..100] of integer;
    groups_count:integer;
    insert:boolean;
  end;

var
  add_step_form: Tadd_step_form;

implementation

{$R *.dfm}

procedure Tadd_step_form.cxDBTextEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var i: integer;
begin
  if Key=VK_RETURN then
    with data_mod do
    begin
      steps_query.Post;
      if insert then
      for i := 1 to groups_count do
      begin
        MyQuery1.SQL.Clear;
        MyQuery1.SQL.Append('INSERT INTO step_dates SET ');
        MyQuery1.SQL.Append('id_step='+IntToStr(steps_query.InsertId)+',');
        MyQuery1.SQL.Append('id_group='+IntToStr(groups_ids[i]));
        MyQuery1.Execute;
      end;
      step_dates_query.ParamByName('id_step').Value:=steps_query.InsertId;
      step_dates_query.ExecSQL;
      //step_dates_query.Edit;
      //steps_query.Edit;
    end;
end;

procedure Tadd_step_form.study_plan_comboPropertiesChange(Sender: TObject);
begin
  //with data_mod.step_dates_query do
  //begin
  //  ParamByName('id_study_plan').Value:=study_plan_combo.EditValue;
  //  ExecSQL;
  //end;
end;

end.
